/*
 * $Id$
 */
package corejs;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class SourceFile implements LineReader {
   
   final BufferedReader _br;
   int _lineNum = 0;
   
   public SourceFile(final Reader br) {
         _br = new BufferedReader(br);
         _lineNum = 0;
   }

   public Line readLine() {
      try {
         final String s = _br.readLine();
         return null == s ? LineReaderSource.EOF_LINE : new Line(_lineNum++, s);
      }
      catch (IOException ex) {
         throw new RuntimeException(ex);
      }
   }
   
   public static void main(final String... args) throws IOException {
      final SourceFile f = new SourceFile(new FileReader("/Temp/test1.js"));
      for (Line l = f.readLine(); l != LineReaderSource.EOF_LINE; l = f.readLine()) {
         System.out.println(l);
      }      
   }
}
